package com.example;

import com.example.config.SpringConfig;
import com.example.service.OrderService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;


public class Main {
    public static void main(String[] args) {
       
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);

        OrderService orderService = context.getBean(OrderService.class);

        System.out.println("===================== 开始测试 add 方法 =====================");
        try {
  
            orderService.add("iPhone 15", 1);
        } catch (Exception e) {
  
            System.out.println("add方法执行失败：" + e.getMessage());
            System.out.println("----------------------------------------");
        }


        System.out.println("\n===================== 开始测试 delete 方法 =====================");
        try {
        
            orderService.delete("华为Mate 60");
        } catch (Exception e) {
            System.out.println("delete方法执行失败：" + e.getMessage());
            System.out.println("----------------------------------------");
        }

        System.out.println("\n===================== 开始测试 find 方法 =====================");
        try {
        
            int count = orderService.find("小米14");
            System.out.println("Main方法中获取的查询结果：" + count);
        } catch (Exception e) {
            System.out.println("find方法执行失败：" + e.getMessage());
        }
        context.close();
    }
}
